import config from 'config'
import httpFetch from 'share/httpFetch'

export default {

  //operationCode：1（代理制单）、2（代理审批）

  //查询代理关系列表
  getAgencyList(operationCode, page, size, keyWords) {
    let url = `${config.baseUrl}/api/bill/proxy/principals?operationCode=${operationCode}&page=${page}&size=${size}`;
    url += keyWords ? `&keyword=${encodeURIComponent(keyWords)}` : '';
    return httpFetch.get(url)
  },

  //删除代理关系
  deleteAgencyItem(params) {
    return httpFetch.delete(`${config.baseUrl}/api/bill/proxy/delete/`, params)
  },

  //查询员工权限 集团模式下
  getEmployeeLimitTenant() {
    return httpFetch.get(`${config.baseUrl}/api/function/profiles`)
  },

  //修改员工权限 集团模式下
  updateEmployeeLimitTenant(params) {
    return httpFetch.post(`${config.baseUrl}/api/function/profiles`, params)
  },

  //查询员工权限
  getEmployeeLimit() {
    return httpFetch.get(`${config.baseUrl}/api/function/profiles/company`)
  },

  //修改员工权限
  updateEmployeeLimit(params) {
    return httpFetch.post(`${config.baseUrl}/api/function/profiles`, params)
  },

  //根据姓名／工号查询人员列表
  getPersonByValue(value, operationCode) {
    let url = `${config.baseUrl}/api/search/users/by/${value}`;
    operationCode && (url += `?isCompany=true&operationCode=${operationCode}`);
    return httpFetch.get(url)
  },

  //根据姓名／工号查询人员列表
  getPersonByValueV2(params) {
    return httpFetch.get(`${config.baseUrl}/api/users/v3/search`, params)
  },

  //根据OID查询人员状态
  getPersonStatusByOid(OID, operationCode) {
    return httpFetch.get(`${config.baseUrl}/api/bill/proxy/principals/check/${OID}?operationCode=${operationCode}`)
  },

  //新建代理
  newAgency(params) {
    return httpFetch.post(`${config.baseUrl}/api/bill/proxy/rules`, params)
  },

  //根据代理OID获取代理信息
  getAgencyInfo(OID, operationCode) {
    return httpFetch.get(`${config.baseUrl}/api/bill/proxy/rules/${OID}?operationCode=${operationCode}`)
  },

  //根据代理OID和用户OID获取代理单据选项
  getAgencyFormList(operationCode, principalOID, proxyOID) {
    return httpFetch.get(`${config.baseUrl}/api/custom/forms/proxy?operationCode=${operationCode}&principalOID=${principalOID}&proxyOID=${proxyOID}`)
  },

}
